package com.summer.main;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.sun.glass.ui.Size;

public class BooleanTest {

    private static String findMoney(String content) {
    	content = content.substring(0, content.lastIndexOf("元")+1);
    	
//    	System.out.println(content);
    	
    	String pattern = "(\\d+\\.\\d{2})元$";
//      String pattern = "(\\d+\\.\\d{1,2})?元";
      Pattern r = Pattern.compile(pattern);
      Matcher m = r.matcher(content);
      String money=null;
      if (m.find()) {
    	  money = m.group(1);
      }
      return money == null ? "0.00~~" : money;
  }
    
    /** 
     * 判断str1中包含str2的个数 
      * @param str1 
     * @param str2 
     * @return counter 
     */  
    public static int countStr(String str1, char str2) {
    	int count = 0;
    	char[] chars = str1.toCharArray();
    	for(char ch : chars){
    		if(str2 == ch)
    			count++;
    	}
    	return count;
    }  
	
	public static void main(String[] args) {
		
//		System.out.println(countStr(cont,'元'));
		
		String[] strList = {
				"成功收款0.01元。享免费提现等更多专属服务，点击查看",
				"成功收款0.01元。0.06元享免费提现等更多专属服务，点击查看",
				"成功收款0.01元",
				"成功收款0.01",
				"成功收款0.01,5000.0",
				"5000.00元，成功收款0.01元",
				"5000.00元5000.00元，成功收款0.01元",
				"唧唧通过扫码向你付款￥5000.00元，成功收款0.01元",
				"成功收款0.01元,享有2000.00元额度优惠，点击查看",
				"成功收款0.01元,享有2000额度优惠，点击查看",
				"您有一笔转账订单请注意查收",
				"唧唧通过扫码向你付款5000.00元，成功收款0.01元",
				"唧唧通过扫码向你付款5000元，成功收款0.01元",
				"唧唧通过扫码向你付款5000，成功收款0.01元",
				"唧唧通过扫码向你付款5000.00，成功收款0.01元",
				"唧唧通过扫码向你付款5000.00，成功收款0.01元,5000.00元",
				"唧唧通过扫码向你付款5000.00，成功收款0.01元,5000",
				"唧唧通过扫码向你付款5000.00，成功收款0.01元,5000元",
		};
		
		for(String str : strList){
			if(countStr(str,'元')>1){
				System.out.println("异常订单");
	            continue;
			}
			System.out.println(findMoney(str));
		}
		
//		A a = null;
//		A b = new A();
////		if(BooleanTools.isNulls(a || a.s)){
////			
////		}
////		if(BooleanTools.isNulls(b || b.s)){
////			
////		}
////		
//		boolean ee;
//		boolean aa = true;
//		boolean bb = true;
//		boolean cc = true;
//		ee = aa;
//		ee &= bb;
//		ee &= cc;
//		if(ee)
//			System.out.println("true");
//		else
//			System.out.println("false");
		
	}
	
	public static class A{
		public Size s;
	}

	public static class BooleanTools{
		
		public static boolean isNulls(Object... objs){
			for(Object obj : objs){
				if(obj==null)
					return false;
			}
			return true;
		}
		
	}
	
}
